import * as THREE from "three";
import { Scene } from "three";
import imgYouzi from "./imgs/youzi.png";

function runQiu(scene: Scene) {
  let geo = new THREE.SphereGeometry(5, 50, 50);
  let map = new THREE.TextureLoader().load(imgYouzi);
  let material = new THREE.MeshPhongMaterial({ color: "#ffffff" });
  let qiu = new THREE.Mesh(geo, material);
  qiu.position.z = -50;
  qiu.position.y = 5;
  qiu.castShadow = true;
  qiu.receiveShadow = true;
  qiu.name = "qiu";
  scene.add(qiu);

  // 灯光
  const spotLight = new THREE.SpotLight(0xffffff);
  spotLight.position.set(0, 20, -60);

  spotLight.castShadow = true;

  spotLight.shadow.mapSize.width = 1024;
  spotLight.shadow.mapSize.height = 1024;

  spotLight.shadow.camera.near = 1;
  spotLight.shadow.camera.far = 4000;
  spotLight.shadow.camera.fov = 30;

  spotLight.lookAt(qiu.position);

  scene.add(spotLight);

  {
    let geo = new THREE.SphereGeometry(5, 50, 50);
    let material = new THREE.MeshPhongMaterial({ color: "#0000ff" });
    let qiu = new THREE.Mesh(geo, material);
    qiu.position.copy(spotLight.position);
    console.log(qiu.position, spotLight.position);
    scene.add(qiu);
  }
}

export default runQiu;
